<?php
require_once ROOT_LIBRARY_UTILITY.DS.'Globals.php';

class BaseController extends Zend_Controller_Action {

    public function init() {
        $this->view->baseUrl = $this->_request->getBaseUrl();
        $this->view->moduleName = $this->_request->getModuleName();
        $this->view->controllerName = $this->_request->getControllerName();
        $this->view->actionName = $this->_request->getActionName();
        $this->view->user = Zend_Auth::getInstance()->getIdentity();
        Globals::getLanguage($this);
        $this->_db = Globals::getDBConnection();

        Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination.phtml');
    }

    public function  preDispatch() {
        if(!Zend_Auth::getInstance()->hasIdentity() && $this->view->moduleName == "backend")
            $this->_redirect ('/backend/auth/login');
    }
}

?>
